import { useDidShow } from "@tarojs/taro";
import { useRef } from "react";

export default (callback: () => void) => {
  const isMounted = useRef(true);
  useDidShow(() => {
    if (!isMounted.current) {
      callback();
    } else {
      isMounted.current = false;
    }
  });
};
